* Figure 9 : Mean outcome variables by village-year insurance coverage status
* Sample used to study household outcomes
* Last Updated, Niriksha Shetty 03/31/206

clear
clear mata
clear matrix
set maxvar 20000
set more off

pwd
cap cd c(`pwd')

estimates clear

use "../dta/reduced-form-master.dta", clear

*Using balanced panel
keep if ex_post_balp==1

* Treatment Expansion not included here, no control countergroup
drop if c_b2009==1

* Easier labelling for graphs
la var w_real_sav "savings (INR)"
la var w_real_lent "money lent out (INR)"
la var w_real_borrow "money borrowed (INR)"
la var w_real_cons "total consumption (INR)"
la var w_real_food_exp "food expenditure (INR)"
la var w_real_nonfood_exp "non-food expenditure (INR)"
la var w_real_durables_exp "durables expenditure (INR)"
la var w_real_events_exp "events expenditure (INR)"
la var w_real_income "annual income(INR)"
la var w_real_gifts_out "gifts/transfers made (INR)"
la var w_real_gifts_in "gifts/transfers received (INR)"
la var food_sufficiency_child "food sufficiency for children"
la var fladder_std "financial situation (sd units)"
la var outlook_std "good things happen (sd units)"
la var control_std "control over life (sd units)"

foreach var of varlist w_real_cons w_real_sav w_real_lent w_real_borrow w_real_food_exp w_real_nonfood_exp w_real_durables_exp w_real_events_exp w_real_income w_real_gifts_out w_real_gifts_in food_sufficiency_child fladder_std outlook_std control_std {
bys mkt_year: egen avg_`var'_b=mean(`var') if bought==1  
bys mkt_year: egen avg_`var'_nbt=mean(`var') if bought == 0 & treat_year == 1 
bys mkt_year: egen avg_`var'_nt=mean(`var') if treat_year == 0 
lab var avg_`var'_b "Treatment: Purchased"
lab var avg_`var'_nbt "Treatment: Did not Purchase"
lab var avg_`var'_nt "Control Group"  
}

foreach var in w_real_cons w_real_sav w_real_lent w_real_borrow w_real_food_exp w_real_nonfood_exp w_real_durables_exp w_real_events_exp w_real_income w_real_gifts_out w_real_gifts_in food_sufficiency_child {
local l`var':variable label `var'
twoway connected  avg_`var'_b avg_`var'_nbt avg_`var'_nt mkt_year, title("`l`var''", size(s)) ylabel(,angle (30)) xlabel(2005(2)2013) xtitle("") graphregion(color(white)) plotregion(icolor(white)) msymbol(T D O)
graph save avg_`var', replace
graph export "../output/graphs/f9_`var'.emf", replace
}  

* different axes
foreach var in fladder_std outlook_std control_std  {
local l`var':variable label `var'
twoway connected  avg_`var'_b avg_`var'_nbt avg_`var'_nt mkt_year, title("`l`var''", size(s)) ylabel(-1 0 1,angle (30)) xlabel(2005(2)2013) xtitle("") graphregion(color(white)) plotregion(icolor(white)) msymbol(T D O)
graph save avg_`var', replace
graph export "../output/graphs/f9_`var'.emf", replace
}
 
* combining graphs
grc1leg avg_w_real_sav.gph avg_w_real_lent.gph avg_w_real_borrow.gph avg_w_real_cons.gph avg_w_real_food_exp.gph avg_w_real_nonfood_exp.gph avg_w_real_durables_exp.gph avg_w_real_events_exp.gph  avg_w_real_gifts_out.gph avg_w_real_income.gph avg_w_real_gifts_in.gph avg_food_sufficiency_child.gph avg_fladder_std.gph avg_outlook_std.gph avg_control_std.gph, graphregion(color(white) lwidth(large)) plotregion(icolor(white)) 
graph export "../output/graphs/f9.emf", replace


